#coding=utf-8
#Boa:FramePanel:PanelHomePage

import wx

from ConfTool27 import conf
from product import CDataRecord

[wxID_PANELHOMEPAGE, wxID_PANELHOMEPAGEBTNACCOUNT, 
 wxID_PANELHOMEPAGEBTNACCOUNTCHECK, wxID_PANELHOMEPAGEBTNCHECKDATA, 
 wxID_PANELHOMEPAGEBTNCOLLECT, wxID_PANELHOMEPAGEBTNCUSTOMER, 
 wxID_PANELHOMEPAGEBTNDELIVERYPLAN, wxID_PANELHOMEPAGEBTNEVENT, 
 wxID_PANELHOMEPAGEBTNEXPENSE, wxID_PANELHOMEPAGEBTNFINANCE, 
 wxID_PANELHOMEPAGEBTNMALL, wxID_PANELHOMEPAGEBTNPEER, 
 wxID_PANELHOMEPAGEBTNPEERLEND, wxID_PANELHOMEPAGEBTNPRODUCT, 
 wxID_PANELHOMEPAGEBTNPURORDER, wxID_PANELHOMEPAGEBTNPURQUERY, 
 wxID_PANELHOMEPAGEBTNRECORD, wxID_PANELHOMEPAGEBTNREPORT, 
 wxID_PANELHOMEPAGEBTNSALEORDER, wxID_PANELHOMEPAGEBTNSALEQUERY, 
 wxID_PANELHOMEPAGEBTNSUPPLIER, wxID_PANELHOMEPAGEBUTTONPROFITREPORT, 
 wxID_PANELHOMEPAGEBUTTON_PURCHASE, wxID_PANELHOMEPAGEBUTTON_ROUTE, 
 wxID_PANELHOMEPAGESTATICBOX1, wxID_PANELHOMEPAGESTATICBOX2, 
 wxID_PANELHOMEPAGESTATICBOX3, wxID_PANELHOMEPAGESTATICBOX4, 
 wxID_PANELHOMEPAGESTATICBOX5, wxID_PANELHOMEPAGESTATICBOX6, 
 wxID_PANELHOMEPAGESTATICBOX7, wxID_PANELHOMEPAGESTATICBOX8, 
 wxID_PANELHOMEPAGESTATICBOX9, wxID_PANELHOMEPAGETCNOTE, 
] = [wx.NewId() for _init_ctrls in range(34)]

class PanelHomePage(wx.Panel):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Panel.__init__(self, id=wxID_PANELHOMEPAGE, name=u'PanelHomePage',
              parent=prnt, pos=wx.Point(77, 39), size=wx.Size(1177, 713),
              style=wx.TAB_TRAVERSAL)
        self.SetClientSize(wx.Size(1161, 675))
        self.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'\u6977\u4f53_GB2312'))
        self.SetBackgroundColour(wx.Colour(183, 209, 173))

        self.btnSaleOrder = wx.Button(id=wxID_PANELHOMEPAGEBTNSALEORDER,
              label=u'\u9500\u552e\u8ba2\u5355', name=u'btnSaleOrder',
              parent=self, pos=wx.Point(96, 56), size=wx.Size(93, 26), style=0)
        self.btnSaleOrder.Bind(wx.EVT_BUTTON, self.OnBtnSaleOrderButton,
              id=wxID_PANELHOMEPAGEBTNSALEORDER)

        self.btnSaleQuery = wx.Button(id=wxID_PANELHOMEPAGEBTNSALEQUERY,
              label=u'\u9500\u552e\u67e5\u8be2', name=u'btnSaleQuery',
              parent=self, pos=wx.Point(96, 96), size=wx.Size(93, 26), style=0)
        self.btnSaleQuery.Bind(wx.EVT_BUTTON, self.OnBtnSaleQueryButton,
              id=wxID_PANELHOMEPAGEBTNSALEQUERY)

        self.btnCollect = wx.Button(id=wxID_PANELHOMEPAGEBTNCOLLECT,
              label=u'\u9500\u552e\u4ed8\u6b3e', name=u'btnCollect',
              parent=self, pos=wx.Point(96, 136), size=wx.Size(93, 26),
              style=0)
        self.btnCollect.Bind(wx.EVT_BUTTON, self.OnBtnCollectButton,
              id=wxID_PANELHOMEPAGEBTNCOLLECT)

        self.btnPurOrder = wx.Button(id=wxID_PANELHOMEPAGEBTNPURORDER,
              label=u'\u91c7\u8d2d\u5355', name=u'btnPurOrder', parent=self,
              pos=wx.Point(320, 56), size=wx.Size(93, 26), style=0)
        self.btnPurOrder.Bind(wx.EVT_BUTTON, self.OnBtnPurOrderButton,
              id=wxID_PANELHOMEPAGEBTNPURORDER)

        self.btnPurQuery = wx.Button(id=wxID_PANELHOMEPAGEBTNPURQUERY,
              label=u'\u91c7\u8d2d\u67e5\u8be2', name=u'btnPurQuery',
              parent=self, pos=wx.Point(320, 96), size=wx.Size(93, 26),
              style=0)
        self.btnPurQuery.Bind(wx.EVT_BUTTON, self.OnBtnPurQueryButton,
              id=wxID_PANELHOMEPAGEBTNPURQUERY)

        self.btnPeerLend = wx.Button(id=wxID_PANELHOMEPAGEBTNPEERLEND,
              label=u'\u540c\u884c\u62c6\u501f', name=u'btnPeerLend',
              parent=self, pos=wx.Point(520, 56), size=wx.Size(93, 26),
              style=0)
        self.btnPeerLend.Bind(wx.EVT_BUTTON, self.OnBtnPeerLendButton,
              id=wxID_PANELHOMEPAGEBTNPEERLEND)

        self.btnCustomer = wx.Button(id=wxID_PANELHOMEPAGEBTNCUSTOMER,
              label=u'\u5ba2\u6237\u4fe1\u606f', name=u'btnCustomer',
              parent=self, pos=wx.Point(96, 248), size=wx.Size(93, 26),
              style=0)
        self.btnCustomer.Bind(wx.EVT_BUTTON, self.OnBtnCustomerButton,
              id=wxID_PANELHOMEPAGEBTNCUSTOMER)

        self.btnSupplier = wx.Button(id=wxID_PANELHOMEPAGEBTNSUPPLIER,
              label=u'\u4f9b\u5e94\u5546\u4fe1\u606f', name=u'btnSupplier',
              parent=self, pos=wx.Point(96, 288), size=wx.Size(93, 26),
              style=0)
        self.btnSupplier.Bind(wx.EVT_BUTTON, self.OnBtnSupplierButton,
              id=wxID_PANELHOMEPAGEBTNSUPPLIER)

        self.btnPeer = wx.Button(id=wxID_PANELHOMEPAGEBTNPEER,
              label=u'\u540c\u884c\u4fe1\u606f', name=u'btnPeer', parent=self,
              pos=wx.Point(96, 328), size=wx.Size(93, 26), style=0)
        self.btnPeer.Bind(wx.EVT_BUTTON, self.OnBtnPeerButton,
              id=wxID_PANELHOMEPAGEBTNPEER)

        self.btnEvent = wx.Button(id=wxID_PANELHOMEPAGEBTNEVENT,
              label=u'\u5b9a\u65f6\u63d0\u9192', name=u'btnEvent', parent=self,
              pos=wx.Point(704, 56), size=wx.Size(93, 26), style=0)
        self.btnEvent.Bind(wx.EVT_BUTTON, self.OnBtnEventButton,
              id=wxID_PANELHOMEPAGEBTNEVENT)

        self.btnRecord = wx.Button(id=wxID_PANELHOMEPAGEBTNRECORD,
              label=u'\u5de5\u4f5c\u8bb0\u5f55', name=u'btnRecord', parent=self,
              pos=wx.Point(704, 96), size=wx.Size(93, 26), style=0)
        self.btnRecord.Bind(wx.EVT_BUTTON, self.OnBtnRecordButton,
              id=wxID_PANELHOMEPAGEBTNRECORD)

        self.staticBox1 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX1,
              label=u'', name='staticBox1', parent=self, pos=wx.Point(72, 40),
              size=wx.Size(144, 140), style=0)

        self.btnProduct = wx.Button(id=wxID_PANELHOMEPAGEBTNPRODUCT,
              label=u'\u5546\u54c1\u4fe1\u606f', name=u'btnProduct',
              parent=self, pos=wx.Point(320, 248), size=wx.Size(93, 26),
              style=0)
        self.btnProduct.Bind(wx.EVT_BUTTON, self.OnBtnProductButton,
              id=wxID_PANELHOMEPAGEBTNPRODUCT)

        self.btnAccount = wx.Button(id=wxID_PANELHOMEPAGEBTNACCOUNT,
              label=u'\u8d44\u91d1\u8d26\u6237', name=u'btnAccount',
              parent=self, pos=wx.Point(520, 248), size=wx.Size(93, 26),
              style=0)
        self.btnAccount.Bind(wx.EVT_BUTTON, self.OnBtnAccountButton,
              id=wxID_PANELHOMEPAGEBTNACCOUNT)

        self.staticBox2 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX2,
              label=u'', name='staticBox2', parent=self, pos=wx.Point(296, 40),
              size=wx.Size(144, 144), style=0)
        self.staticBox2.SetBackgroundColour(wx.Colour(0, 0, 0))

        self.staticBox3 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX3,
              label=u'', name='staticBox3', parent=self, pos=wx.Point(496, 40),
              size=wx.Size(144, 144), style=0)

        self.staticBox4 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX4,
              label=u'', name='staticBox4', parent=self, pos=wx.Point(680, 40),
              size=wx.Size(144, 144), style=0)

        self.staticBox5 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX5,
              label=u'', name='staticBox5', parent=self, pos=wx.Point(72, 224),
              size=wx.Size(144, 152), style=0)

        self.staticBox6 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX6,
              label=u'', name='staticBox6', parent=self, pos=wx.Point(296, 224),
              size=wx.Size(144, 152), style=0)

        self.staticBox7 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX7,
              label=u'', name='staticBox7', parent=self, pos=wx.Point(680, 224),
              size=wx.Size(144, 152), style=0)

        self.btnDeliveryPlan = wx.Button(id=wxID_PANELHOMEPAGEBTNDELIVERYPLAN,
              label=u'\u76f4\u9001\u8ba1\u5212', name=u'btnDeliveryPlan',
              parent=self, pos=wx.Point(704, 248), size=wx.Size(93, 26),
              style=0)
        self.btnDeliveryPlan.Bind(wx.EVT_BUTTON, self.OnBtnDeliveryPlanButton,
              id=wxID_PANELHOMEPAGEBTNDELIVERYPLAN)

        self.btnExpense = wx.Button(id=wxID_PANELHOMEPAGEBTNEXPENSE,
              label=u'\u8d39\u7528\u652f\u51fa', name=u'btnExpense',
              parent=self, pos=wx.Point(520, 288), size=wx.Size(93, 26),
              style=0)
        self.btnExpense.Bind(wx.EVT_BUTTON, self.OnBtnExpenseButton,
              id=wxID_PANELHOMEPAGEBTNEXPENSE)

        self.staticBox8 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX8,
              label=u'', name='staticBox8', parent=self, pos=wx.Point(496, 224),
              size=wx.Size(144, 152), style=0)

        self.staticBox9 = wx.StaticBox(id=wxID_PANELHOMEPAGESTATICBOX9,
              label=u'', name='staticBox9', parent=self, pos=wx.Point(72, 424),
              size=wx.Size(144, 152), style=0)

        self.btnCheckData = wx.Button(id=wxID_PANELHOMEPAGEBTNCHECKDATA,
              label=u'\u6570\u636e\u6821\u5bf9', name=u'btnCheckData',
              parent=self, pos=wx.Point(96, 456), size=wx.Size(93, 26),
              style=0)
        self.btnCheckData.Enable(True)
        self.btnCheckData.Bind(wx.EVT_BUTTON, self.OnBtnCheckDataButton,
              id=wxID_PANELHOMEPAGEBTNCHECKDATA)

        self.btnReport = wx.Button(id=wxID_PANELHOMEPAGEBTNREPORT,
              label=u'\u7edf\u8ba1\u62a5\u8868', name=u'btnReport', parent=self,
              pos=wx.Point(320, 328), size=wx.Size(93, 26), style=0)
        self.btnReport.Bind(wx.EVT_BUTTON, self.OnBtnReportButton,
              id=wxID_PANELHOMEPAGEBTNREPORT)

        self.button_purchase = wx.Button(id=wxID_PANELHOMEPAGEBUTTON_PURCHASE,
              label=u'\u5546\u54c1\u91c7\u8d2d', name=u'button_purchase',
              parent=self, pos=wx.Point(320, 288), size=wx.Size(93, 26),
              style=0)
        self.button_purchase.Bind(wx.EVT_BUTTON, self.OnButton_purchaseButton,
              id=wxID_PANELHOMEPAGEBUTTON_PURCHASE)

        self.button_route = wx.Button(id=wxID_PANELHOMEPAGEBUTTON_ROUTE,
              label=u'\u9001\u8d27\u8def\u7ebf', name=u'button_route',
              parent=self, pos=wx.Point(704, 288), size=wx.Size(93, 26),
              style=0)
        self.button_route.Bind(wx.EVT_BUTTON, self.OnButton_routeButton,
              id=wxID_PANELHOMEPAGEBUTTON_ROUTE)

        self.buttonProfitReport = wx.Button(id=wxID_PANELHOMEPAGEBUTTONPROFITREPORT,
              label=u'\u5229\u6da6\u62a5\u8868', name=u'buttonProfitReport',
              parent=self, pos=wx.Point(96, 496), size=wx.Size(93, 26),
              style=0)
        self.buttonProfitReport.Show(False)
        self.buttonProfitReport.Bind(wx.EVT_BUTTON,
              self.OnButtonProfitReportButton,
              id=wxID_PANELHOMEPAGEBUTTONPROFITREPORT)

        self.btnAccountCheck = wx.Button(id=wxID_PANELHOMEPAGEBTNACCOUNTCHECK,
              label=u'\u8d26\u6237\u5bf9\u8d26', name=u'btnAccountCheck',
              parent=self, pos=wx.Point(520, 328), size=wx.Size(93, 26),
              style=0)
        self.btnAccountCheck.Bind(wx.EVT_BUTTON, self.OnBtnAccountCheckButton,
              id=wxID_PANELHOMEPAGEBTNACCOUNTCHECK)

        self.btnFinance = wx.Button(id=wxID_PANELHOMEPAGEBTNFINANCE,
              label=u'\u8d22\u52a1\u62a5\u8868', name=u'btnFinance',
              parent=self, pos=wx.Point(96, 536), size=wx.Size(93, 26),
              style=0)
        self.btnFinance.Bind(wx.EVT_BUTTON, self.OnBtnFinanceButton,
              id=wxID_PANELHOMEPAGEBTNFINANCE)

        self.tcNote = wx.TextCtrl(id=wxID_PANELHOMEPAGETCNOTE, name=u'tcNote',
              parent=self, pos=wx.Point(840, 48), size=wx.Size(304, 568),
              style=wx.STATIC_BORDER | wx.TE_MULTILINE, value=u'')
        self.tcNote.SetBackgroundColour(wx.Colour(183, 209, 173))
        self.tcNote.SetAutoLayout(True)

        self.btnMall = wx.Button(id=wxID_PANELHOMEPAGEBTNMALL,
              label=u'\u5546\u57ce\u7edf\u8ba1', name=u'btnMall', parent=self,
              pos=wx.Point(320, 456), size=wx.Size(93, 26), style=0)
        self.btnMall.Bind(wx.EVT_BUTTON, self.OnBtnMallButton,
              id=wxID_PANELHOMEPAGEBTNMALL)

    def __init__(self, parent):
        self._init_ctrls(parent)
        
        self.main = self.GetParent().GetParent()
        
        b_boss = conf.getint('permission', 'boss', 0)
        self.buttonProfitReport.Show(True if b_boss==1 else False)
        
        self.btnExpense.Enable(True if b_boss==1 else False)
        self.btnAccountCheck.Show(True if b_boss==1 else False)
        self.btnAccount.Enable(True if b_boss==1 else False)
        self.btnCheckData.Show(True if b_boss==1 else False)
        self.btnPeerLend.Enable(True if b_boss==1 else False)
        self.btnPeer.Show(True if b_boss==1 else False)
        self.btnMall.Show(True if b_boss==1 else False)
        self.btnReport.Show(True if b_boss==1 else False)
        
        self.iNote = conf.getint('login', 'note', 0)
        if self.iNote != 0:
            self.tcNote.SetValue(CDataRecord.getNote(self.iNote))
        else:
            self.tcNote.Show(False)
        
        #self.btnFinance.Show(False)
        self.btnFinance.Show(True if b_boss==1 else False)

    def OnBtnSaleOrderButton(self, event):
        self.main.newSaleOrder()

    def OnBtnSaleQueryButton(self, event):
        self.main.showSaleHistory()

    def OnBtnCollectButton(self, event):
        self.main.newCollect()

    def OnBtnPurOrderButton(self, event):
        self.main.newPurOrder()

    def OnBtnPurQueryButton(self, event):
        self.main.showPurHistory()

    def OnBtnPeerLendButton(self, event):
        self.main.newLend()

    def OnBtnCustomerButton(self, event):
        self.main.showCustomer()

    def OnBtnSupplierButton(self, event):
        self.main.showSupplier()

    def OnBtnPeerButton(self, event):
        self.main.showPeer()

    def OnBtnEventButton(self, event):
        self.main.showEvent()

    def OnBtnRecordButton(self, event):
        self.main.showRecord()

    def OnBtnProductButton(self, event):
        self.main.showProduct()

    def OnBtnAccountButton(self, event):
        self.main.showAccountDetail()

    def OnBtnFundCustomerButton(self, event):
        self.main.showFundCustomer()

    def OnBtnFundSupplierButton(self, event):
        self.main.showFundSupplier()

    def OnBtnDeliveryPlanButton(self, event):
        self.main.newDeliveryPlan()

    def OnBtnExpenseButton(self, event):
        
        self.main.showExpense()

    def OnBtnCheckDataButton(self, event):
        self.main.showValidation()

    def OnBtnStatButton(self, event):
        event.Skip()

    def OnBtnReportButton(self, event):
        self.main.showReport()

    def OnButton_purchaseButton(self, event):
        self.main.showReportPurchase()

    def OnButton_routeButton(self, event):
        self.main.showReportRouteList()

    def OnButtonProfitReportButton(self, event):
        self.main.showProfitProduct()
        


    def OnBtnAccountCheckButton(self, event):
        import DlgAccountCheck
        
        dlg = DlgAccountCheck.create(self)
        dlg.ShowModal()

    def OnBtnFinanceButton(self, event):
        self.main.showReportFinance()
        
    def saveNote(self):
        if self.iNote != 0:
            obj = CDataRecord.getData({"id":self.iNote})
            obj.setValue(CDataRecord.fi_content, self.tcNote.GetValue())
            obj.update()

    def OnBtnMallButton(self, event):
        self.main.showMallReport()
        
        
        
        
        
